package cn.chenhuanming.shh.authentication.server;

import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;

/**
 * Created by Administrator on 2017-03-23.
 */
@SpringBootApplication
@RestController
public class AuthenticationApplication extends SpringBootServletInitializer {

    @RequestMapping({ "/user", "/me" })
    public Principal user(Principal principal) {
        return principal;
    }


    public static void main(String[] args) throws Exception {
        SpringApplication.run(AuthenticationApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(AuthenticationApplication.class);
    }

    @Bean
    public static BeanFactoryPostProcessor beanFactoryPostProcessor(){
        return new SerializationBeanFactoryPostProcessor();
    }

}
